import { collaboraSavecoll,collaboraGetCollList,collaboraDelcoll,sysgetMenus,editcoll,sysgetmenusByUserId } from '@/services/overviewRobots';

export default {
  namespace: 'teamWord',

  state: {
   
  },
  effects: {
    *sysgetmenusByUserId({ payload, callback }, { call, put }) { // 根据状态或角色名查询角色列表分页
      const response = yield call(sysgetmenusByUserId, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *collaboraSavecoll({ payload, callback }, { call, put }) { // 添加协作开发用户
      const response = yield call(collaboraSavecoll, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *collaboraGetCollList({ payload, callback }, { call, put }) { // 开发人员列表
      const response = yield call(collaboraGetCollList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *collaboraDelcoll({ payload, callback }, { call, put }) { // 删除协作开发用户
      const response = yield call(collaboraDelcoll, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *sysgetMenus({ payload, callback }, { call, put }) { // 获取菜单
      const response = yield call(sysgetMenus, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *editcoll({ payload, callback }, { call, put }) { // 编辑协作开发
      const response = yield call(editcoll, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
  },

  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
    fetchb(state,{payload}){
      return {
        ...state,
        ...payload,
      };
    },
    clear() {
      return {
        total:'',
        list:[]
      };
    },
  },
};
